/* 1732. 找到最高海拔 */
/**
 * @param {number[]} gain
 * @return {number}
 */
/* 
    前缀和
    还原数组求最大值
*/
var largestAltitude = function (gain) {
	let ans = 0,
		sum = 0
	for (const x of gain) {
		sum += x
		ans = Math.max(ans, sum)
	}
	return ans
}
const res = largestAltitude([-4, -3, -2, -1, 4, 3, 2])
console.log('largestAltitude :>>', res)
